home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / ipx751.arc / IPXUNIT.PAS < prev    next >
Pascal/Delphi Source File  |  1988-08-29  |  8KB  |  318 lines

  1. Unit IPXUnit;
  2.  
  3. { IPXUNIT.PAS - IPX/SPX Functions Unit                      08-24-88 }
  4.  
  5. (*
  6.  
  7.   Version 1.0  8-24-88 : Basic Unit Development / Prototyping
  8.   Version 1.1  8-26-88 : Implement SPX Functions
  9.  
  10. *)
  11.  
  12. Interface
  13.  
  14. Uses Dos;
  15.  
  16. Const
  17.  
  18.    MaxAESEvents = 32;
  19.  
  20.    IPXDataSeg : Word = 0;  {Copy of this Unit's Data Segment base}
  21.  
  22. Type
  23.  
  24.    IPXNetAddr    = Array[1..4] of Byte;
  25.    IPXNodeAddr   = Array[1..6] of Byte;
  26.  
  27.    IPXAddress = Record
  28.                    Network : IPXNetAddr;
  29.                    Node    : IPXNodeAddr;
  30.                    Socket  : Word;
  31.                 End;
  32.  
  33.    IPXHeaderRec = Record
  34.                      CheckSum    : Word;
  35.                      PacketLen   : Word;
  36.                      TransCtrl   : Byte;
  37.                      PacketType  : Byte;
  38.                      DestAdd     : IPXAddress;
  39.                      SourceAdd   : IPXAddress;
  40.                   End;
  41.  
  42.    ECBRec = Record
  43.                Link       : Array[1..2] of Word;
  44.                ESRAddr    : Array[1..2] of Word;
  45.                InUse      : Byte;
  46.                CompCode   : Byte;
  47.                Socket     : Word;
  48.                IPXWork    : Array[1..4] of Byte;
  49.                DriverWork : Array[1..12] of Byte;
  50.                ImmedAddr  : IPXNodeAddr;
  51.                FragCount  : Word;
  52.             End;
  53.  
  54.    FragmentDesc = Record
  55.                      FragAddr   : Array[1..2] of Word;
  56.                      FragLength : Word;
  57.                   End;
  58.  
  59.    AESRec = Record
  60.                Link       : Array[1..2] of Word;
  61.                ESRAddr    : Array[1..2] of Word;
  62.                InUse      : Byte;
  63.                WorkSpace  : Array[1..5] of Byte;
  64.             End;
  65.  
  66.    SPXHeaderRec = Record
  67.                      CheckSum    : Word;
  68.                      PacketLen   : Word;
  69.                      TransCtrl   : Byte;
  70.                      PacketType  : Byte;
  71.                      DestAdd     : IPXAddress;
  72.                      SourceAdd   : IPXAddress;
  73.                      ConnControl : Byte;
  74.                      DataType    : Byte;
  75.                      SourceConnID: Word;
  76.                      DestConnID  : Word;
  77.                      SeqNumber   : Word;
  78.                      AckNumber   : Word;
  79.                      AllocNumber : Word;
  80.                   End;
  81.  
  82.  
  83. Var
  84.    IPXResultCode : Byte;  {All Result Codes returned here}
  85.    IPXTransTime  : Word;  {All Transport Times returned here}
  86.  
  87.    AES_ECB       : Array[1..MaxAESEvents] of AESRec;
  88.  
  89.  
  90.  
  91. Procedure IPXOpenSocket (OpenMode: Word; Var Socket: Word);
  92. Procedure IPXCloseSocket (Socket: Word);
  93. Procedure IPXGetTarget (Target: IPXAddress; Var LocalTarget: IPXNodeAddr);
  94. Procedure IPXSendPacket (Var ECB: ECBRec);
  95. Procedure IPXListenPacket (Var ECB: ECBRec);
  96. Procedure IPXScheduleEvent (Var ECB: ECBRec; DelayTime: Word);
  97. Procedure IPXCancelEvent (Var ECB: ECBRec);
  98. Procedure IPXRelinquish;
  99. Procedure IPXNotifyDisconnect (Target: IPXAddress);
  100. Procedure AESScheduleEvent (Var AES: AESRec; DelayTime: Word);
  101. Procedure AESCancelEvent (Var AES: AESRec);
  102. Procedure AESStartEvent (EventNo,DelayTime: Word);
  103. Procedure AESAbortEvent (EventNo: Word);
  104. Function  AESEventTrip (EventNo: Word): Boolean;
  105.  
  106.  
  107.  
  108. Implementation
  109.  
  110. { * Local unit variables * }
  111.  
  112. Var
  113.    Regs : Registers;
  114.  
  115. Procedure ClearRegs;
  116. Begin
  117.    FillChar(Regs,SizeOf(Regs),0);
  118. End;
  119.  
  120. Procedure IPXOpenSocket (OpenMode: Word; Var Socket: Word);
  121. Begin
  122.    ClearRegs;
  123.    If not (OpenMode in [0,$FF]) then  {Invalid Open Mode}
  124.       Begin
  125.          IPXResultCode := 1;
  126.          Exit;
  127.       End;
  128.    Regs.Ax := OpenMode;
  129.    Regs.Bx := 0;
  130.    Regs.Dx := Swap(Socket);
  131.    Intr($7A,Regs);
  132.    If Socket=0 then Socket := Swap(Regs.Dx);
  133.    IPXResultCode := Lo(Regs.Ax);
  134. End;
  135.  
  136. Procedure IPXCloseSocket (Socket: Word);
  137. Begin
  138.    ClearRegs;
  139.    Regs.Bx := $0001;
  140.    Regs.Dx := Swap(Socket);
  141.    Intr($7A,Regs);
  142.    IPXResultCode := 0;
  143. End;
  144.  
  145. Procedure IPXGetTarget (Target: IPXAddress; Var LocalTarget: IPXNodeAddr);
  146. Begin
  147.    ClearRegs;
  148.    With Regs do
  149.       Begin
  150.          Bx := $0002;
  151.          Es := Seg(Target);
  152.          Si := Ofs(Target);
  153.          Di := Ofs(LocalTarget);
  154.       End;
  155.    Intr($7A,Regs);
  156.    IPXResultCode := Lo(Regs.Ax);
  157.    If IPXResultCode=0 then IPXTransTime := Regs.Cx;
  158. End;
  159.  
  160. Procedure IPXSendPacket (Var ECB: ECBRec);
  161. Begin
  162.    ClearRegs;
  163.    With Regs do
  164.       Begin
  165.          Bx := $0003;
  166.          Es := Seg(ECB);
  167.          Si := Ofs(ECB);
  168.       End;
  169.    Intr($7A,Regs);
  170.    IPXResultCode := 0;
  171. End;
  172.  
  173. Procedure IPXListenPacket (Var ECB: ECBRec);
  174. Begin
  175.    ClearRegs;
  176.    With Regs do
  177.       Begin
  178.          Bx := $0004;
  179.          Es := Seg(ECB);
  180.          Si := Ofs(ECB);
  181.       End;
  182.    Intr($7A,Regs);
  183.    IPXResultCode := 0;
  184. End;
  185.  
  186. Procedure IPXScheduleEvent (Var ECB: ECBRec; DelayTime: Word);
  187. Begin
  188.    ClearRegs;
  189.    With Regs do
  190.       Begin
  191.          Ax := DelayTime;
  192.          Bx := $0005;
  193.          Es := Seg(ECB);
  194.          Si := Ofs(ECB);
  195.       End;
  196.    Intr($7A,Regs);
  197.    IPXResultCode := 0;
  198. End;
  199.  
  200. Procedure IPXCancelEvent (Var ECB: ECBRec);
  201. Begin
  202.    ClearRegs;
  203.    With Regs do
  204.       Begin
  205.          Bx := $0006;
  206.          Es := Seg(ECB);
  207.          Si := Ofs(ECB);
  208.       End;
  209.    Intr($7A,Regs);
  210.    IPXResultCode := Lo(Regs.Ax);
  211. End;
  212.  
  213. Procedure IPXRelinquish;
  214. Begin
  215.    ClearRegs;
  216.    Regs.Bx := $000A;
  217.    Intr($7A,Regs);
  218. End;
  219.  
  220. Procedure IPXNotifyDisconnect (Target: IPXAddress);
  221. Begin
  222.    ClearRegs;
  223.    With Regs do
  224.       Begin
  225.          Bx := $000B;
  226.          Es := Seg(Target);
  227.          Si := Ofs(Target);
  228.       End;
  229.    Intr($7A,Regs);
  230.    IPXResultCode := 0;
  231. End;
  232.  
  233. Procedure AESScheduleEvent (Var AES: AESRec; DelayTime: Word);
  234. Begin
  235.    ClearRegs;
  236.    With Regs do
  237.       Begin
  238.          Ax := DelayTime;
  239.          Bx := $0007;
  240.          Es := Seg(AES);
  241.          Si := Ofs(AES);
  242.       End;
  243.    Intr($7A,Regs);
  244.    IPXResultCode := 0;
  245. End;
  246.  
  247. Procedure AESCancelEvent (Var AES: AESRec);
  248. Begin
  249.    ClearRegs;
  250.    With Regs do
  251.       Begin
  252.          Bx := $0006;
  253.          Es := Seg(AES);
  254.          Si := Ofs(AES);
  255.       End;
  256.    Intr($7A,Regs);
  257.    IPXResultCode := Lo(Regs.Ax);
  258. End;
  259.  
  260. Procedure AESStartEvent (EventNo,DelayTime: Word);
  261. Begin
  262.    If EventNo>MaxAESEvents then  {Out of range...}
  263.       Begin
  264.          IPXResultCode := 2;
  265.          Exit;
  266.       End;
  267.    FillChar(AES_ECB[EventNo],SizeOf(AES_ECB[EventNo]),0);
  268.    With AES_ECB[EventNo] do
  269.       Begin
  270.          ESRAddr[1] := 0;  {ESRs not implemented...}
  271.          ESRAddr[2] := 0;  {... at this time ......}
  272.       End;
  273.    AESScheduleEvent(AES_ECB[EventNo],DelayTime);
  274. End;
  275.  
  276. Procedure AESABortEvent (EventNo: Word);
  277. Begin
  278.    If EventNo>MaxAESEvents then  {Out of range...}
  279.       Begin
  280.          IPXResultCode := 2;
  281.          Exit;
  282.       End;
  283.    ClearRegs;
  284.    With Regs do
  285.       Begin
  286.          Bx := $0006;
  287.          Es := Seg(AES_ECB[EventNo]);
  288.          Si := Ofs(AES_ECB[EventNo]);
  289.       End;
  290.    Intr($7A,Regs);
  291.    IPXResultCode := Lo(Regs.Ax);
  292. End;
  293.  
  294. Function AESEventTrip (EventNo: Word): Boolean;
  295. Begin
  296.    If EventNo>MaxAESEvents then  {Out of range...}
  297.       Begin
  298.          IPXResultCode := 2;
  299.          AESEventTrip := False;
  300.          Exit;
  301.       End;
  302.    AESEventTrip := (AES_ECB[EventNo].InUse=0);
  303. End;
  304.  
  305.  
  306. { * Unit Initialization * }
  307.  
  308. Begin
  309.  
  310.    IPXDataSeg := Seg(IPXResultCode);  {Initialize Unit's DS segment base}
  311.  
  312.    IPXResultCode := 0;
  313.    IPXTransTime := 0;
  314.  
  315.    FillChar(AES_ECB,SizeOf(AES_ECB),0);
  316.  
  317. End.
  318.